<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>购物车</title>

		<link rel="stylesheet" href="{{__PUBLIC__}}/Home/less/buycar.css" />
		<link rel="stylesheet" href="{{__PUBLIC__}}/Home/less/index.css" />
		<link rel="stylesheet" href="{{__PUBLIC__}}/Home/less/bottom.css" />
		<link rel="stylesheet" href="{{__PUBLIC__}}/Home/bootstrap/css/bootstrap.css" />
		<link rel="stylesheet" href="{{__PUBLIC__}}/shoppingcar/css/style.css" />
		<script src="{{__PUBLIC__}}/Home/city/jquery-1.8.2.min.js"></script>
		<script src="{{__PUBLIC__}}/shoppingcar/js/demo.js"></script>	
	</head>

	<body>
		<!--购物车头部-->
		<div id="carhead">
			<div class="carhead">
				<img src="{{__PUBLIC__}}/Home/images/vancl-logo.png" alt="" />
				<div class="chright">
					{{if value="(isset($_SESSION['username']))"}}
					<span class="welcome">您好,<a href="">{{$_SESSION['username']}}</a>!</span>
					<span class="login"style="width:140px;margin-left:-30px;">
						<a href="{{U('Login/out')}}">退出登录</a>|<a href="{{U('Login/index')}}">更换用户</a>
					</span>
                    {{else}}
                    <span class="welcome">您好,欢迎光临凡客诚品!</span>
					<span class="login">
						<a href="{{U('Login/index')}}">登陆</a>|<a href="{{U('Register/index')}}">注册</a>
					</span>
					{{endif}}
					<span class='help'><a href="">帮助中心</a></span>
				</div>
			</div>

		</div>
		<div id="buycar">
			<ul class="tul">
				<li class='lone'><span class="word lone">1.我的购物车</span> </li>
				<li class='ltwo'><span class="word">2.填写核对信息单</span></li>
				<li class='lthree'><span class="word">3.成功提交订单</span></li>
			</ul>
			<div class="cfirst">
				<div class="title">	
					<div class="tt">
						<span class="tbj"></span>
						<p class='mycar'>我的购物车</p>
					</div>
					<p class="notice"><span class='notice'>温馨提示：</span>1.选购清单中的商品无法保留库存，请您及时结算。2.商品的价格和库存将以订单提交时为准。3.促销活动满减优惠将均摊至商品小计中。</p>
				</div>
			<!--购物车表单-->
				<div class="buylist">
					<div class="catbox">

	<table id="cartTable">
		<thead>
			<tr>
				<th>
					<label>
					<input class="check-all check" type="checkbox"/>&nbsp;全选
					</label>
					</th>
				<th>商品</th>
				<th>单价</th>
				<th>数量</th>
				<th>小计</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			{{foreach from="$data" key="$k" value="$v"}}
				
			<tr>
				<td ><input class="check-one check" type="checkbox"/></td>
				
				<td class="goods">
					<!--图片-->
					<img src="{{$v['photo']}}" alt=""/>
					<!--商品名-->
					<span style="width:100px;">{{$v['name']}}</span>
					<!--样式-->
					{{foreach from="$v['options']"value="$ov"}}
					<span style="width:100px;">{{$ov}}</span>
					{{endforeach}}
					</td>
				<!--单价-->
				<td class="price" >{{$v['price']}}</td>
				
				<!--数量-->
				<!--修改购物车商品数量的异步请求-->
				<script type="text/javascript" >
					$(function(){
//						点击减一
						$('.count>.reduce').click(function(){
//							获得购物车商品的id
							var c=$(this).attr('sid');
//							var price=$(this).attr('prc');
							
							
//							获得点击前的数量
							
//							alert(price);
							var num=$('input[name=num]').val()*1;
							
							if(num>1){
								num=num-1;
								$.ajax({
									url:'{{U('edit')}}',
									data:{sid:c,num:num},
									type:'post',
									dataType:'json',
	//								页面不需要分配数据时可以不写
									success:function(phpData){
										
									}
								})
							}
								
//							alert(oldnum);
							
						})
//						点击增加一
						$('.count>.add').click(function(){
//							var price=$(this).attr('price')*1;
							
							
//							获得购物车商品的id
							var c=$(this).attr('sid');
//							alert(c);
//							获得点击前的数量
							var num=$('input[name=num]').val()*1;
							
							num +=1;
							
//							alert(num);
							$.ajax({
								url:'{{U('edit')}}',
								data:{sid:c,num:num},
								type:'post',
								dataType:'json',
//								页面不需要分配数据时可以不写
								success:function(phpData){
								
								}
							})
						})
					})
				</script>
				<!--点击数量修改ajax-->
				<script></script>
				<td class="count">
					<span class="reduce"sid="{{$k}}"prc="{{$v['price']}}">-</span>
					<input class="count-input" type="text"name="num" value="{{$v['num']}}"style="width:25px;height:25px;font-size: 15px;"/>
					<span class="add"sid="{{$k}}"prc="{{$v['price']}}">+</span></td>
				<!--小计总价-->
				<td class="subtotal">{{$v['total']}}</td>
				<!--删除单件商品的异步请求-->
				<script type="text/javascript">
					$(function(){
						$('.operation .delete').click(function(){
//							获得购物车商品的id
							var c=$(this).attr('sid');
//							alert(c);
							$.ajax({
								url:'{{U('del')}}',
								data:{sid:c},
								type:'post',
								dataType:'json',
								success:function(phpData){
									
								}
							})
						})
					})
				
				</script>
				<!--把购物车里的商品id放入自定义属性中-->
				<td class="operation"><span class="delete" sid="{{$k}}">删除</span></td>
			</tr>
				
			{{endforeach}}
		</tbody>
	</table>
	
	<div class="foot" id="foot">
		
		<label class="fl select-all"><input type="checkbox" class="check-all check"/>&nbsp;全选</label>
		
		
		<span class="fl delete" id="deleteAll" ><a href="">删除</a></span>
		<!--结算判断是否登陆-->
		
		<div class="fr closing">
			{{if value="isset($_SESSION['username'])&&isset($_SESSION['uid'])"}}
			<a href="{{U('BuycarTwo/index',array('gid'=>$total['gid']))}}"class="gojiesuan">结 算</a>
			{{else}}
			<a href="{{U('Login/index')}}"class="gojiesuan">结 算</a>
			{{endif}}
			</div>
		
		<div class="fr total">合计：￥<span id="priceTotal">{{$total['total']}}</span></div>
		<div class="fr selected" id="selected">已选商品<span id="selectedTotal">{{$total['total_rows']}}</span>件</div>
		<div class="selected-view">
			<div id="selectedViewList" class="clearfix">
				<div><img src="images/1.jpg"><span>取消选择</span></div>
			</div>
			<span class="arrow">◆<span>◆</span></span>
		</div>
	</div>

</div>
				</div>
			</div>
		<!--底部-->
		<div id="bottom">
			<div class="bottom">
				<p>Copyright 2007 - 2015 vancl.com All Rights Reserved 京ICP证100557号 京公网安备11011502002400号 出版物经营许可证新出发京批字第直110138号</p>
				<ul>
					<li>
						<a href="" class='one'></a>
					</li>
					<li>
						<a href="" class='two'></a>
					</li>
					<li>
						<a href="" class='three'></a>
					</li>
					<li>
						<a href="" class='four'></a>
					</li>

					<li>
						<a href="" class='five'></a>
					</li>
					<li>
						<a href=""><img src="{{__PUBLIC__}}/Home/images/kexin_brand_for_others.png" alt="" /></a>
					</li>

				</ul>
			</div>
		</div>
	</body>

</html>	
			
			